
%!TEX program = xelatex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt]{article} 

\input{wang_preamble.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%页面的高度与宽度、上边界与左边界-------正常打印边界
%\addtolength{\textheight}{1cm}
%\addtolength{\voffset}{-1cm}
\addtolength{\textwidth}{1.5cm}
\addtolength{\hoffset}{-1cm}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titling}
\setlength{\droptitle}{-2cm}   % This is your set screw

%%文档的题目、作者与日期

%\author{王立庆（2019级数学与应用数学1班）}
\author{姓名 \underline{\hspace{4cm}}\,\,\,\, \underline{\hspace{4cm}} \,\,\,\, \underline{\hspace{4cm}} }
%\title{高等代数第六章：向量空间}
\title{统计软件测验解答 }
%\date{\vspace{-3ex}}
\renewcommand{\today}{\number\year \,年 \number\month \,月 \number\day \,日}
\date{2023年4月10日}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}

%5.2\# 1, 2, 3, 4, 5.  
%5.3\# 1, 20, 22, 35, 36. 
%5.4\# 1, 4, 13, 14, 20. 
%6.2\# 1, 2.  
%6.3\# 4, 6. 
%6.6\# 5, 12. 
%7.2\# 1, 3, 4, 6, 10, 11, 12, 14, 16, 17, 18, 20, 21, 24, 26. 
%7.6\# 6, 7, 8. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %1
在一批产品中我们随机地检查了 10 箱，发现每箱中的不合格品数如下。
\begin{center}
\begin{tabular}{cccccccccc} \hline 
4& 5& 6& 0& 3& 1& 4& 2& 1& 4 \\ \hline 
\end{tabular}
\end{center}
计算样本均值、样本方差和样本标准差。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：

\begin{lstlisting}[language=R]
> x=c(4,5,6,0,3,1,4,2,1,4)> mean(x)[1] 3> var(x)[1] 3.777778> sd(x)[1] 1.943651
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %2
从正态总体 $N(100,4)$ 抽取样本容量分别为 15 和 20 的两个独立样本，样本均值分别记为 $\bar{x},\bar{y}$.  
分别使用理论计算和随机数模拟，计算概率 $\mathbb{P}(|\bar{x}-\bar{y}|>0.2)$. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：%理论计算略。

\begin{lstlisting}[language=R]
> x=replicate(1000, mean(rnorm(15,100,2))-mean(rnorm(20,100,2)))> sum(abs(x)>0.2)/1000[1] 0.772
\end{lstlisting}

}

\vspace{0.2cm}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %3
设 $x_1,x_2,\cdots,x_{16}$ 是来自正态总体 $N(8,4)$ 的样本。
记 $x_{(1)},x_{(2)}, \cdots, x_{(16)}$ 是从小到大的次序统计量。
分别使用理论计算和随机数模拟，计算概率 $\mathbb{P}(x_{(1)}  > 5)$. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：%理论计算略。

\begin{lstlisting}[language=R]
> x=replicate(1000,min(rnorm(16,8,2)))> sum(x>5)/1000[1] 0.334
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %4
巳知某种材料的抗压强度 $X\sim N(\mu, \sigma^2)$. 现随机地抽取 10 个试件进行抗压试验，测得数据如下。
\begin{center}
\begin{tabular}{cccccccccc} \hline 
482& 493& 457& 471& 510& 446& 435& 418& 394& 469 \\ \hline 
\end{tabular}
\end{center}
\begin{enumerate}
\item  求平均抗压强度 $\mu$ 的置信水平为 95\%的置信区间。
\item  若巳知 $\sigma = 30$, 求平均抗压强度 $\mu$ 的置信水平为 95\%的置信区间。
\item  求 $\sigma$ 的置信水平为 95\%的置信区间。
\end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：
\begin{enumerate}
\item  均值的置信区间为 $[432.3, 482.7]$. 
\begin{lstlisting}[language=R]
> x=c(482,493,457,471,510,446,435,418,394,469)> t.test(x)	One Sample t-testdata:  xt = 41.08, df = 9, p-value = 1.495e-11alternative hypothesis: true mean is not equal to 095 percent confidence interval: 432.3069 482.6931sample estimates:mean of x     457.5 
\end{lstlisting}

\item  均值的置信区间为 $[438.9, 476.1]$. 
\begin{lstlisting}[language=R]
> xbar=mean(x)> sigma=30> n=length(x)> xbar-sigma/sqrt(n)*qnorm(0.975)[1] 438.9061> xbar+sigma/sqrt(n)*qnorm(0.975)[1] 476.0939
\end{lstlisting}

\item  标准差的置信区间为 $[24.22, 64.29]$. 
\begin{lstlisting}[language=R]
> sigma.sq.hatL=(n-1)*var(x)/qchisq(0.975,n-1)> sqrt(sigma.sq.hatL)[1] 24.22389> sigma.sq.hatR=(n-1)*var(x)/qchisq(0.025,n-1)> sqrt(sigma.sq.hatR)[1] 64.29357
\end{lstlisting}

\end{enumerate}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %5
设一批钢管内径服从正态分布 $N(\mu, \sigma^2)$, 其中 $\sigma^2$ 未知。从中抽取 10 根，测得其内径（单位：mm）如下。
\begin{center}
\begin{tabular}{ccccc} \hline 
100. 36 & 100. 31 & 99. 99 & 100.11 & 100. 64 \\ \hline 
100.85 & 99.42 & 99.91 & 99.35 & 100.10 \\ \hline 
\end{tabular}
\end{center}
设 $\alpha = 0.05$. 检验假设 $H_0: \mu = 100\,\, \text{v.s.}\,\, H_1: \mu \neq 100$.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：接受零假设。

\begin{lstlisting}[language=R]
> x=c(100.36, 100.31, 99.99, 100.11, 100.64, +     100.85, 99.42, 99.91, 99.35, 100.10)> t.test(x,mu=100)	One Sample t-testdata:  xt = 0.69098, df = 9, p-value = 0.507alternative hypothesis: true mean is not equal to 10095 percent confidence interval:  99.76352 100.44448sample estimates:mean of x   100.104 
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %6
两台车床生产同—种滚珠，滚珠直径服从正态分布。从中分别抽取 8 个和 9 个产品，测得其直径如下。
\begin{center}
\begin{tabular}{c|ccccccccc} \hline 
甲车床& 15.0& 14.5& 15.2& 15.5& 14.8& 15.1& 15.2& 14.8& \\ \hline 
乙车床& 15.2& 15.0& 14.8& 15.2& 15.0& 15.0& 14.8& 15.1& 14.8 \\ \hline  
\end{tabular}
\end{center}
设 $\alpha = 0.05$. 比较两台车床生产的滚珠直径的方差是否有显著差异。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：无显著差异。

\begin{lstlisting}[language=R]
> x=c(15.0, 14.5, 15.2, 15.5, 14.8, 15.1, 15.2, 14.8)> y=c(15.2, 15.0, 14.8, 15.2, 15.0, 15.0, 14.8, 15.1, 14.8)> lathe=c(rep(1,8),rep(2,9))> mydata=data.frame(diam=c(x,y),lathe=lathe)> mydata$lathe=factor(mydata$lathe)> var.test(diam~lathe,data=mydata)	F test to compare two variancesdata:  diam by latheF = 3.6588, num df = 7, denom df = 8, p-value = 0.08919alternative hypothesis: true ratio of variances is not equal to 195 percent confidence interval:  0.8079418 17.9257790sample estimates:ratio of variances           3.658815 

> myf=var(x)/var(y)> mypv=2*(1-pf(myf,7,8))> print(mypv)[1] 0.0891917
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %7
在检验了一个车间生产的 20 个轴承外座圈的内径（单位：mm）后得到下面数据如下。
\begin{center}
\begin{tabular}{cccccccccc} \hline 
15.04& 15.36& 14.57& 14.53& 15.57& 14.69& 15.37& 14.66& 14.52& 15.41 \\ \hline 
15.34& 14.28& 15.01& 14.76& 14.38& 15.87& 13.66& 14.97& 15.29& 14.95 \\ \hline 
\end{tabular}
\end{center}
设 $\alpha=0.05$. 请用 Shapiro-Wilk 方法检验这组数据是否来自正态分布。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：来自正态分布。

\begin{lstlisting}[language=R]
> x=c(15.04, 15.36, 14.57, 14.53, 15.57, 14.69, 15.37, 14.66, 14.52, 15.41,+     15.34, 14.28, 15.01, 14.76, 14.38, 15.87, 13.66, 14.97, 15.29, 14.95)> shapiro.test(x)	Shapiro-Wilk normality testdata:  xW = 0.97442, p-value = 0.8439
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %8
某饮料商用两种不同配方推出了两种新的饮料，现抽取了 10 位消费者，让他们分别品尝两种饮料并加以评分，
从不喜欢到喜欢，评分为 1-10，评分结果如下。
\begin{center}
\begin{tabular}{c|cccccccccc} \hline 
品尝者& 1& 2& 3& 4& 5& 6& 7& 8& 9& 10 \\ \hline  
A饮料& 10& 8& 6& 8& 7& 5& 1& 3& 9& 7 \\ \hline  
B饮料& 6& 5& 2& 2& 4& 6& 4& 5& 9& 8 \\ \hline
\end{tabular}
\end{center}
采用符号秩和检验方法，问两种饮料评分是否有显著差异？

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\vspace{0.2cm}

{\color{red}解答：无显著差异。

\begin{lstlisting}[language=R]
> x=c(10, 8, 6, 8, 7, 5, 1, 3, 9, 7)> y=c(6, 5, 2, 2, 4, 6, 4, 5, 9, 8)> wilcox.test(x,y)	Wilcoxon rank sum test with continuity correctiondata:  x and yW = 66.5, p-value = 0.2237alternative hypothesis: true location shift is not equal to 0

> wilcox.test(x,y,paired=T)	Wilcoxon signed rank test with continuity correctiondata:  x and yV = 34, p-value = 0.1902alternative hypothesis: true location shift is not equal to 0
\end{lstlisting}

}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{enumerate}

\end{document}





